package fileFolderCmd;

import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;




	//Send questions, comments, bug reports, etc. to the authors:

	//Rob Warner (rwarner@interspatial.com)
	//Robert Harris (rbrt_harris@yahoo.com)

	import org.eclipse.swt.*;
	import org.eclipse.swt.events.*;
	import org.eclipse.swt.layout.*;
	import org.eclipse.swt.widgets.*;

	/**
	 * This class demonstrates the DirectoryDialog class
	 */
	public class FolderDialogHIDE {
		  private static Shell shell;

		    public static void SWTApp(Display display) {

		        shell = new Shell(display);

		        shell.setText("DirectoryDialog");

		        initUI();

		        shell.setSize(350, 250);
		        shell.setLocation(300, 300);

		        shell.open();

		        while (!shell.isDisposed()) {
		          if (!display.readAndDispatch()) {
		            display.sleep();
		          }
		        }
		    }


		    public static void initUI() {


		        final Label status = new Label(shell, SWT.BORDER);
		        status.setText("Ready");
		        FormLayout layout = new FormLayout();
		        shell.setLayout(layout);

		        FormData labelData = new FormData();
		        labelData.left = new FormAttachment(0);
		        labelData.right = new FormAttachment(100);
		        labelData.bottom = new FormAttachment(100);
		        status.setLayoutData(labelData);

		        shell.addMouseListener(new MouseAdapter() {

		            @Override
		            public void mouseDown(MouseEvent event) {
		                DirectoryDialog dialog = new DirectoryDialog(shell);
		                String path = dialog.open();
		                if (path != null)
		                    status.setText(path);
		            }

		        });
		    }


		    public static void main(String[] args) {
		        Display display = new Display();
		        //new SWTApp(display);
		        SWTApp(display);
		        display.dispose();
		    }

}
